﻿namespace OOP
{
    using System;

    public class Call
    {
        // date, time, dialed phone number and duration (in seconds).
        private DateTime dateAndTime;
        private string phoneNumber;
        private int duration; // for me, it must be TimeSpan

        public Call(string phoneNumber)
        {
            this.PhoneNumber = phoneNumber;

            this.dateAndTime = DateTime.Now;

            // DateTime callDateTime = DateTime.Now;
            // this.date = string.Format("{0}.{1}.{2}", callDateTime.Date.Day, callDateTime.Date.Month, callDateTime.Date.Year);
            // this.time = string.Format("{0}:{1}", callDateTime.Hour, callDateTime.Minute, callDateTime.Second);
        }

        public DateTime DateAndTime
        {
            get
            {
                return this.dateAndTime;
            }
        }

        public string PhoneNumber
        {
            get
            {
                return this.phoneNumber;
            }

            private set
            {
                this.phoneNumber = value;
            }
        }

        public int Duration
        {
            get
            {
                return this.duration;
            }

            private set
            {
                this.duration = value;
            }
        }

        public void EndCall()
        {
            DateTime timeAtEndCall = DateTime.Now;
            this.Duration = (timeAtEndCall - this.DateAndTime).Seconds;
        }

        public override string ToString()
        {
            return this.PhoneNumber + Environment.NewLine + this.Duration + Environment.NewLine + this.DateAndTime;
        }
    }
}